package com.example.admin.yuejian_22.Fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.admin.yuejian_22.Adapter.ClubListAdapter;
import com.example.admin.yuejian_22.Bean.ClubList;
import com.example.admin.yuejian_22.Listener.UserListener;
import com.example.admin.yuejian_22.Model.UserModel;
import com.example.admin.yuejian_22.R;

import java.util.List;


public class ClubPFragment extends Fragment {
    public RecyclerView recyclerView;
    private View view = null;
    UserListener userListener = new UserListener() {
        @Override
        public void onResponse(Object beanobject) {
            recyclerView.setAdapter(new ClubListAdapter(getActivity(),(List<ClubList>)beanobject));
        }
        @Override
        public void onFail(String msg) {

        }
    };

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_club_p, container, false);
        initRecyclerView(view);
        UserModel model = new UserModel();
        model.getAllClub(userListener);
        return view;
    }

    public  void initRecyclerView(View view){
        recyclerView=(RecyclerView) view.findViewById(R.id.recycleView_p);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }
}
